Why do these two SQL queries return a different number of rows